package com.template.states;

import com.google.common.collect.ImmutableList;
import com.template.contracts.IouContract;
import net.corda.core.contracts.BelongsToContract;
import net.corda.core.contracts.ContractState;
import net.corda.core.identity.AbstractParty;
import net.corda.core.identity.Party;

import java.util.List;

/**
 * IOU State
 *
 * @author yangjie
 * @date 2020/12/04
 */
@BelongsToContract(IouContract.class)
public class IouState implements ContractState {

    private final int value;
    private final Party lender;
    private final Party borrower;

    public IouState(int value, Party lender, Party borrower) {
        this.value = value;
        this.lender = lender;
        this.borrower = borrower;
    }

    /**
     * This method will indicate who are the participants and required signers when
     * this state is used in a transaction.
     */
    @Override
    public List<AbstractParty> getParticipants() {
        return ImmutableList.of(lender, borrower);
    }

    public int getValue() {
        return value;
    }

    public Party getLender() {
        return lender;
    }

    public Party getBorrower() {
        return borrower;
    }
}